import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'

// https://vite.dev/config/
export default defineConfig({
  server: {
    host: '192.168.0.53',
    port: 6001,
    proxy: {
      '/api/': {
        target: 'http://localhost:8360/',
        // target: 'http://192.168.100.68:8080/',
        changeOrigin: true,
        rewrite: (p) => p.replace(new RegExp(`^/api/`), ''),
      },
      '/static/': {
        target: 'http://localhost:8360/static/',
        // target: 'http://192.168.100.68:8080/',
        changeOrigin: true,
        rewrite: (p) => p.replace(new RegExp(`^/static/`), ''),
      },
    }
  },
  plugins: [
    vue(),
    vueJsx(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
